
$(document).ready(function(){
	var rootPath = getRootPath();
	var userId = 84;
	
	$.ajax({
		method : 'get',
		url : rootPath+'/wechat/api/maintain/repairs?userId='+userId,
		error:function(XMLHttpRequest, ajaxOptions, thrownError){
			alert("连接服务器错误!");
		},
		success : function(resultData){
			
			var wholeHtml = '';
			
			$.each(resultData,function(maintainIndex,maintainObj){
				
				var maintainHtml = '';
				
				var mainTainappointType = '';
				
				var mainTainapplyStatus = '';

				var resnId = maintainObj.resnId
				
				if(maintainObj.appointType==0){
					mainTainappointType = '保养';
				}
				else if(maintainObj.appointType==1){
					mainTainappointType = '活动';
				}
				else if(maintainObj.appointType==2){
					mainTainappointType = '维修';
				}
				else{ 
					mainTainappointType = '其他';
				}
				
				if(maintainObj.applyStatus==1){
					mainTainapplyStatus = '已预约';
				}
				else if(maintainObj.applyStatus==2){
					mainTainapplyStatus = '已取消';
				}
				else{
					mainTainapplyStatus = '受理中';
				}
				
				maintainHtml = maintainHtml   + '<div class="panel panel-default">'
				  							  +   '<a href="maintaininfor.html?resnId='+resnId+'" class="list-group-item clearfix">'
				  							  +     '<div style="width:70%;float:left">'
				  							  + 	  '<p>'
				  							  + 	    '<span style="color:blue">'+ mainTainappointType +'</span>&nbsp;&nbsp;'
				  							  +			'<span>'+ maintainObj.tmWxMaintenanceSchemeId +'</span>'
				  							  +		  '</p>'
				  							  +		  '<p>'
				  							  +		    '<span>'+ maintainObj.modelName +'</span>'
				  							  +		  '</p>'
				  							  +		  '<p>'
				  							  +			'<span>'+ maintainObj.registNo +'</span>'
				  							  +		  '</p>'
				  							  +		  '<p>'
				  							  +			'预约时间：<span>'+ maintainObj.reseApplStartTime +'</span>'
				  							  +		  '</p>'
				  							  + 	'</div>'
				  							  + 	'<div style="width:20%;float:right">'
				  							  +  	  '<br><br>'
				  							  +		  '<p>'
				  						      + 		'<span class="glyphicon glyphicon-chevron-right"></span>'
				  						      +	      '</p>'
				  						      +		  '<br>'
				  							  +   	  '<p class="status">'
				  							  + 		'<span style="color:red">'+ mainTainapplyStatus +'</span>'
				  							  +  	   '</p>'
				  							  +		 '</div>'
				  							  + 	'</a>'
				  							  + '</div>'
				
				wholeHtml += maintainHtml;
			});
			
			$("#maintain").append(wholeHtml);
		}
	});
})
